home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / mm / alloc.c.D next >
Text File  |  1990-07-25  |  5KB  |  127 lines

  1. *** /tmp/,RCSt1022393    Wed Jul 25 13:59:37 1990
  2. --- alloc.c    Mon Jul 23 10:56:03 1990
  3. ***************
  4. *** 15,16 ****
  5. --- 15,17 ----
  6.    *   max_hole:    returns the largest hole currently available
  7. +  *   mem_left:    returns the sum of the sizes of all current holes
  8.    */
  9. ***************
  10. *** 17,21 ****
  11.   
  12. ! #include "../h/const.h"
  13. ! #include "../h/type.h"
  14. ! #include "const.h"
  15.   
  16. --- 18,20 ----
  17.   
  18. ! #include "mm.h"
  19.   
  20. ***************
  21. *** 34,35 ****
  22. --- 33,37 ----
  23.   
  24. + FORWARD void del_slot();
  25. + FORWARD void merge();
  26.   /*===========================================================================*
  27. ***************
  28. *** 76,78 ****
  29.    *===========================================================================*/
  30. ! PUBLIC free_mem(base, clicks)
  31.   phys_clicks base;        /* base address of block to free */
  32. --- 78,80 ----
  33.    *===========================================================================*/
  34. ! PUBLIC void free_mem(base, clicks)
  35.   phys_clicks base;        /* base address of block to free */
  36. ***************
  37. *** 122,124 ****
  38.    *===========================================================================*/
  39. ! PRIVATE del_slot(prev_ptr, hp)
  40.   register struct hole *prev_ptr;    /* pointer to hole entry just ahead of 'hp' */
  41. --- 124,126 ----
  42.    *===========================================================================*/
  43. ! PRIVATE void del_slot(prev_ptr, hp)
  44.   register struct hole *prev_ptr;    /* pointer to hole entry just ahead of 'hp' */
  45. ***************
  46. *** 145,147 ****
  47.    *===========================================================================*/
  48. ! PRIVATE merge(hp)
  49.   register struct hole *hp;    /* ptr to hole to merge with its successors */
  50. --- 147,149 ----
  51.    *===========================================================================*/
  52. ! PRIVATE void merge(hp)
  53.   register struct hole *hp;    /* ptr to hole to merge with its successors */
  54. ***************
  55. *** 201,204 ****
  56.    *===========================================================================*/
  57. ! PUBLIC mem_init(clicks)
  58. ! phys_clicks clicks;        /* amount of memory available */
  59.   {
  60. --- 203,205 ----
  61.    *===========================================================================*/
  62. ! PUBLIC void mem_init()
  63.   {
  64. ***************
  65. *** 207,213 ****
  66.    * a linked list of table entries that are not in use.  Initially, the former
  67. !  * list has one entry, a single hole encompassing all of memory, and the second
  68. !  * list links together all the remaining table slots.  As memory becomes more
  69. !  * fragmented in the course of time (i.e., the initial big hole breaks up into
  70. !  * many small holes), new table slots are needed to represent them.  These
  71. !  * slots are taken from the list headed by 'free_slots'.
  72.    */
  73. --- 208,214 ----
  74.    * a linked list of table entries that are not in use.  Initially, the former
  75. !  * list has one entry for each chunk of physical memory, and the second
  76. !  * list links together the remaining table slots.  As memory becomes more
  77. !  * fragmented in the course of time (i.e., the initial big holes break up into
  78. !  * smaller holes), new table slots are needed to represent them.  These slots
  79. !  * are taken from the list headed by 'free_slots'.
  80.    */
  81. ***************
  82. *** 215,224 ****
  83.     register struct hole *hp;
  84.   
  85.     for (hp = &hole[0]; hp < &hole[NR_HOLES]; hp++) hp->h_next = hp + 1;
  86. -   hole[0].h_next = NIL_HOLE;    /* only 1 big hole initially */
  87.     hole[NR_HOLES-1].h_next = NIL_HOLE;
  88. !   hole_head = &hole[0];
  89. !   free_slots = &hole[1];
  90. !   hole[0].h_base = 0;
  91. !   hole[0].h_len = clicks;
  92.   }
  93. --- 216,247 ----
  94.     register struct hole *hp;
  95. +   phys_clicks base;        /* base address of chunk */
  96. +   phys_clicks size;        /* size of chunk */
  97.   
  98. +   /* Put all holes on the free list. */
  99.     for (hp = &hole[0]; hp < &hole[NR_HOLES]; hp++) hp->h_next = hp + 1;
  100.     hole[NR_HOLES-1].h_next = NIL_HOLE;
  101. !   hole_head = NIL_HOLE;
  102. !   free_slots = &hole[0];
  103. !   /* Allocate a hole for each chunk of physical memory. */
  104. !   while ( (size = get_mem(&base, FALSE)) != 0)
  105. !     free_mem(base, size);
  106. ! }
  107. ! /*===========================================================================*
  108. !  *                mem_left                     *
  109. !  *===========================================================================*/
  110. ! PUBLIC phys_clicks mem_left()
  111. ! {
  112. ! /* Determine how much memory is left.  This procedure is called just after
  113. !  * initialization to find the original amount.
  114. !  */
  115. !   register struct hole *hp;
  116. !   phys_clicks tot;
  117. !   for (hp = hole_head, tot = 0; hp != NIL_HOLE; hp = hp->h_next)
  118. !     tot += hp->h_len;
  119. !   return(tot);
  120.   }
  121.